#include "Date.h"

#include <ctime>

const char* Date::DaysDefinitions[]  = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
const char* Date::MonthDefinitions[] = {"January" , "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

Date* Date::nowDate = new Date(0, Date::eMonth::January, 0, 0, 0);

Date::Date(int day,eMonth month,int year, short hour,short minutes)
	: day(day), month(month), year(year), hour(hour), minutes(minutes)
{

}

ostream& operator<<(ostream& os, const Date& d)
{
	os << "Date={Day=" << d.day << ", Month=" << 
		Date::MonthDefinitions[d.month-1] << ", Year=" << d.year << ", Time=" << d.hour << ":" << d.minutes << "}";

	return os;
}

void Date::operator=(const Date& other) const
{

}

Date* Date::Now()
{
	time_t now = time(0);
	tm *ltm = localtime(&now);

	nowDate->day		= ltm->tm_mday;
	nowDate->month		= (Date::eMonth) ltm->tm_mon;
	nowDate->year		= ltm->tm_year+1900;
	nowDate->hour		=  ltm->tm_hour;
	nowDate->minutes	= ltm->tm_min;

	return nowDate;
}